<!--
 * @Author: your name
 * @Date: 2022-04-06 09:44:13
 * @LastEditTime: 2022-04-06 09:45:49
 * @LastEditors: your name
 * @Description: 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 * @FilePath: \geyao\geyao\宏任务和微任务220406.html
-->
<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>宏任务和微任务</title>
</head>

<body>
  <script>
    console.log(100)
    setTimeout(() => {
      console.log(200)
    })
    Promise.resolve().then(() => {
      console.log(300)
    })
    console.log(400)
    // 答案为： 100 400 300 200
    // setTimeout是个宏任务，而pormise是个微任务，微任务要比宏任务执行的要早
  </script>
</body>

</html>